package singleton;

//饿汉式
public class CreatSingleton {
    private static CreatSingleton singleton = new CreatSingleton();
    private CreatSingleton() {
        System.out.println(Thread.currentThread().getName()+"正在调用构造方法...");
    }
    public static CreatSingleton getSingleton() {
        return singleton;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                CreatSingleton.getSingleton();
            },String.valueOf(i)).start();

        }
    }
}
